#ifndef CORE_UTILS_H
#define CORE_UTILS_H

#include <QString>
#include <QTime>

class CoreUtils
{
public:

    static QString GetHHMMSS( int msecs, bool forceHours )
    {
        QTime len( 0, 0, 0, 0);
        len = len.addMSecs( msecs );

        QString formatString;

        if ( !forceHours && len.hour() == 0 )
        {
            formatString = "mm:ss";
        } else
        {
            formatString = "hh:mm:ss";
        }

        return len.toString( formatString );
    }

    static inline QString GetTimePosition( int msecs )
    {
        QTime len = QTime().addMSecs( msecs );
        QString formatString = "mm:ss:zzz";

        if( len.hour() > 0 )
        {
            formatString = "hh:mm:ss:zzz";
        }

        return len.toString( formatString );
    }

    static inline QString GetSpeedPerc( float tempo )
    {
        int perc = tempo * 100;
        return QString::number( perc ) + "%";
    }

    static QString GetPitchString( int pitch )
    {
        QString pitchDescription;

        if( pitch == 0 )
        {
            pitchDescription = "original pitch";
        } else
        {
            if( pitch > 0 )
            {
                pitchDescription = "+";
            }

            pitchDescription += QString::number( pitch );

            if( pitch > 1 || pitch < -1 )
            {
                pitchDescription += " semitones";
            } else
            {
                pitchDescription += " semitone";
            }
        }

        return pitchDescription;
    }

};

#endif // CORE_UTILS_H
